package bitwise;

import org.testng.annotations.Test;

/**
 * 移位操作
 */
public class Bitwise {




    //
    @Test
    private void t1() {
        // 2^10，1左移10位
        System.out.println(1 << 10);

        // 2^11，2左移10位
        System.out.println(2 << 10);

        // 10000000 = 2的7次幂，右移3位
        System.out.println(128 >> 3);
    }

    @Test
    public void testBitwise() {
        int a = 0b1010; // 10
        int b = 0b1100; // 12
        System.out.println(a);
        System.out.println(b);
        System.out.println(a & b);
        System.out.println(a | b);
        System.out.println(a ^ b);
        System.out.println(~a);
        System.out.println(a << 1);
        System.out.println(a >> 1);
        System.out.println(a >>> 1);
        System.out.println(a << 2);
        System.out.println(a >> 2);
        System.out.println(a >>> 2);
        System.out.println(a << 3);
        System.out.println(a >> 3);
    }



}
